<!--
Zeke Elder - zbe@andrew.cmu.edu
Amal Chemmany - achemman@andrew.cmu.edu
Nishant Kumar - nkumar1@andrew.cmu.edu
15-637
4/2/2012
-->
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<html>
<head>
<c:if test="${user == null}">
	<c:redirect url="welcome.jsp" />
</c:if>
<script src="js/fithub.js"></script>
<title>Welcome to FitHub!</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link href="css/groups.css" type="text/css" rel="stylesheet">
		<link rel="stylesheet" href="./css/colorbox.css" />
		<script src="./js/jquery.min.js"></script>
		<script src="./js/jquery.colorbox.js"></script>
		<script>
			$(document).ready(function(){
				$(".iframe").colorbox();
				$(".callbacks").colorbox({
					iframe:true, width:"70%", height:"80%",
					onClosed:function(){ window.location.reload(); }
				});
				
			});
		</script>
</head>
<body>

	<!-- include header.jsp -->
	<jsp:include page="./header.jsp" flush="false" />


	<div id="maindiv" class="body_container">
		<div id="friends_bar">
			<form action="search.html">
				<table>
					<tbody>
						<tr>
							<th colspan="4" id="friends_title">Members</th>
						</tr>
						<c:forEach var="entry" items="${memberList}">
							<tr id="${entry.userName}" class="userentryshow">
								<th colspan="2" class="friend_img"><img
									src="./image.do?userId=${entry.userId}" alt="pinocchio thum">
								</th>
								<td class="friend_name">${entry.userName}</td>
							</tr>
							</div>
						</c:forEach>
						<tr>
							<td colspan="3"><input id="search_input"
								onkeyup="manageList(this)" name="search_friend"
								value="Search Member"
								onfocus="if (value == 'Search Member') {value=''}" type="text">
							</td>
						</tr>
					</tbody>
				</table>
			</form>
		</div>
		<div id="people_bar">
			<h1>${group.groupName}</h1>
			<h2>${group.groupDesc}</h2>
			<div id="groupJoinButton">
				<c:if test="${groupButton == 'join'}">
					<input type="button" value="Join Group"
						onclick="window.location='./joinGroup.do?groupId=${group.groupId}'" />
				</c:if>
				<c:if test="${groupButton == 'leave'}">
					<input type="button" value="Leave Group"
						onclick="window.location='./leaveGroup.do?groupId=${group.groupId}'" />
				</c:if>
				<c:if test="${groupButton == 'invite'}">
					<input type="button" value="Invite to Group"
						onclick="window.location='./showInvite.do?groupId=${group.groupId}'" />
				</c:if>
			</div>
			<c:if test="${groupButton != NULL}">
				<div id="newsfeed_title">
					News Feed <br /> <a class='callbacks'
						href="showStory.do?postType=group&groupId=${group.groupId}">Post
						a new story</a>
				</div>
				<br />
				<table>
					<c:forEach var="entry" items="${groupPosts}">
						<div id="story1" class="story">
							[${entry.user.firstName} - ${entry.date}] ${entry.post}
							<c:if test="${entry.user.userId == user.userId}">
								<input type="button" value="X" id="story1"
									onclick="window.location='deletePosts.do?postId=${entry.postId}'" />
							</c:if>
						</div>
						<br />
						<div class="comment">
							<c:forEach var="commentEntry" items="${entry.comments}">
								<c:if test="${commentEntry != null}">
									<div id="story1_comment1">
										[${commentEntry.user.firstName} - ${commentEntry.date}]
										${commentEntry.comment}
										<c:if test="${commentEntry.user.userId == user.userId}">
											<input type="button" value="X" id="story1"
												onclick="window.location='deleteComments.do?commentId=${commentEntry.commentId}'" />
										</c:if>
									</div>
								</c:if>
							</c:forEach>
							<a class='callbacks' href="showComment.do?postId=${entry.postId}">add
								comment</a>
						</div>
						<hr>
					</c:forEach>
				</table>
			</c:if>
		</div>
	</div>
</body>
</html>